package cfdt.ldl.signature.api.feign.fallback;

import cfdt.common.enums.CommonCodeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import cfdt.common.vo.ObjectBaseResponse;
import cfdt.ldl.signature.api.feign.SignatureFeign;
import cfdt.ldl.signature.api.request.SignatrueRequest;
import cfdt.ldl.signature.api.response.SignatureResponse;
import feign.hystrix.FallbackFactory;

/**
 * 签名验签-FallBack
 *
 * <pre>
 * Modify Information:
 * Author       Date          Description
 * ============ ============= ============================
 * wangxiao      2021年7月29日下午1:57:24      创建FallBack
 *
 * </pre>
 */
@Component
public class SignatureFallBack implements FallbackFactory<SignatureFeign> {
    
    private final Logger logger = LoggerFactory.getLogger(getClass().getName());

    @Override
    public SignatureFeign create(Throwable cause) {
        
        logger.error("请求签名验签服务异常", cause);

        return new SignatureFeign() {
  
            @Override
            public ObjectBaseResponse<SignatureResponse> sign(SignatrueRequest signatrueRequest) {
                return ObjectBaseResponse.error(CommonCodeEnum.CODE_1001);
            }

            @Override
            public ObjectBaseResponse<SignatureResponse> verify(SignatrueRequest signatrueRequest) {
                return ObjectBaseResponse.error(CommonCodeEnum.CODE_1001);
            }
        };
    }

}
